package com.authine.cloudpivot.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@Getter
public enum TableNameEnum {
    DFL("DFL", "iknn4_house,iknn4_resident","东风路街道"),
    FRBL("FRBL", "iknn4_house,iknn4_resident","芙蓉北路街道"),
    HS("HS", "iknn4_house,iknn4_resident","洪山街道"),
    LDH("LDH", "iknn4_house,iknn4_resident","捞刀河街道"),
    QZH("QZH", "iknn4_house,iknn4_resident","青竹湖街道"),
    QST("QST", "iknn4_house,iknn4_resident","清水塘街道"),
    WLY("WLY", "iknn4_house,iknn4_resident","望麓园街道"),
    XF("XF", "iknn4_house,iknn4_resident","秀峰街道"),
    YH("YH", "iknn4_house,iknn4_resident","月湖街道"),
    LYH("LYH", "iknn4_house,iknn4_resident","浏阳河街道"),
    XH("XH", "iknn4_house,iknn4_resident","新河街道"),
    XP("XP", "iknn4_house,iknn4_resident","沙坪街道"),
    SFP("SFP", "iknn4_house,iknn4_resident","四方坪街道"),
    TTJ("TTJ", "iknn4_house,iknn4_resident","通泰街街道"),
    WJL("WJL", "iknn4_house,iknn4_resident","伍家岭街道"),
    XYL("XYL", "iknn4_house,iknn4_resident","湘雅路街道")
    ;

    private String code;
    private String tableNames;
    private String description;

    TableNameEnum(String code, String tableNames,String description) {
        this.code = code;
        this.tableNames = tableNames;
        this.description=description;
    }

    public static Map<String, String> convertToMap() {
        Map<String, String> mapResult = new HashMap<>();
        Arrays.stream(TableNameEnum.values()).forEach(tableName -> {
            mapResult.put(tableName.getDescription(),tableName.getCode());
        });
        return mapResult;
    }

    public static String getTableNameByCodes(String code){
        for (TableNameEnum tableName : TableNameEnum.values()) {
            if (tableName.code .equals(code)) {
                return tableName.getTableNames();
            }
        }
        return null;
    }

    public static String getDescrptionByCodes(String code){
        for (TableNameEnum tableName : TableNameEnum.values()) {
            if (tableName.code .equals(code)) {
                return tableName.getDescription();
            }
        }
        return null;
    }

}
